﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="CadastroPessoaFisica.aspx.cs" Inherits="SisVenda.Web.Restrito.CadastroPessoaFisica" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<script type="text/javascript">
/*
* Corrige posição do calendar extender no IE (AjaxToolKit)
*/
function CorrigePosicaoCalendarIE(idElemento, alturaInput) {
    $('input[id*="tbxDataNasci_CalendarExtender"]').click(function() {
        ResistrarInterval($(this), alturaInput);
    });

    $('input[id*="tbxDataNasci_CalendarExtender"]').focus(function() {
        ResistrarInterval($(this), alturaInput);
    });
}

function ResistrarInterval(campo, alturaInput) {
    var intervalo = window.setInterval(function() {
        if ($(".ajax__calendar_container").is(":visible")) {
            $(".ajax__calendar_container").css('left', $(campo).position().left + 0);
            $(".ajax__calendar_container").css('top', $(campo).position().top + alturaInput);
            clearInterval(intervalo);
        }
    }, 50);
</script>

<script src="../Scripts/MSGAguarde.js" type="text/javascript"></script>

    <asp:Panel ID="pnlConsultaCliente" runat="server" 
            DefaultButton="btnLocalizarCliente" GroupingText="Localizar Pessoa Física">
        <div>
        <table width="100%">
            <tr> 
                <td style="text-align: center; width: 40%">
                    <asp:Label ID="lblCPFLocalizar" runat="server" Text="CPF:" />
                    <asp:RequiredFieldValidator ID="rfvCanalEntrada" runat="server" ControlToValidate="tbxCPFLocalizar"
                        ErrorMessage="Campo Obrigatório." ToolTip="Campo Obrigatório." ValidationGroup="Canal">
                    </asp:RequiredFieldValidator>
                    <act:ValidatorCalloutExtender ID="rfvCanalEntrada_ValidatorCalloutExtender" runat="server"
                        Enabled="True" TargetControlID="rfvCanalEntrada">
                    </act:ValidatorCalloutExtender>
                    <asp:TextBox ID="tbxCPFLocalizar" runat="server" SkinID="CpfCnpj"></asp:TextBox>
                    <asp:MaskedEditExtender ID="tbxCPFLocalizar_MaskedEditExtender" runat="server" 
                        CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder="" 
                        CultureDateFormat="" CultureDatePlaceholder="" CultureDecimalPlaceholder="" 
                        CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True" 
                        Mask="99\.999\.999/9999\-99" SkinID="Cpf" TargetControlID="tbxCPFLocalizar">
                    </asp:MaskedEditExtender>
                    &nbsp;<asp:Button ID="btnLocalizarCliente" runat="server" 
                       SkinID="Pesquisar" ValidationGroup="Canal" Text="Pesquisar" 
                        onclick="btnLocalizarCliente_Click" />
                </td>
            </tr>
        </table>
        </div>
    </asp:Panel>
    <asp:Panel ID="pnlTotal" runat="server" Visible="false">
           <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
           <ContentTemplate>
              <asp:Panel ID="pnlDadosPessoais" runat="server" GroupingText="Dados Pessoais" SkinID="SecaoCampos">
                <div>
                  <table width="100%">
                    <tr>     
                     <td> 
                            <asp:Label ID="lblNomeCompletoC" Text="Nome:" runat="server" />
                                <br />
                                <asp:TextBox ID="tbxNome" runat="server" SkinID="Nome"></asp:TextBox>
                            </td>
                        <td>
                            <asp:Label ID="lblCPF" runat="server" Text="CPF:" />
                            <br />
                            <asp:TextBox ID="tbxcpf" runat="server" AutoPostBack="True" SkinID="CpfCnpj"></asp:TextBox>
                            <asp:MaskedEditExtender ID="tbxcpf_MaskedEditExtender" runat="server" 
                                CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder="" 
                                CultureDateFormat="" CultureDatePlaceholder="" CultureDecimalPlaceholder="" 
                                CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True" 
                                Mask="999-999-999-99" TargetControlID="tbxcpf">
                            </asp:MaskedEditExtender>
                        </td>
                        <td>
                            <asp:Label ID="lblRg" runat="server" Text="RG:" />
                         <br />
                            <asp:TextBox ID="tbxRG" runat="server" SkinID="RG"></asp:TextBox>
                        </td>
                        <td>
                            <asp:Label ID="lblSexo" runat="server" Text="Sexo:" />
                            <br />
                            <asp:DropDownList ID="ddlSexo" runat="server" SkinID="SEXO" >
                                <asp:ListItem Value="F">Feminino</asp:ListItem>
                                <asp:ListItem Value="M">Masculino</asp:ListItem>
                            </asp:DropDownList>
                         </td>
                         <td>
                            <asp:Label ID="lblDataNasc" runat="server" Text="Data Nascimento:" />
                            <br />
                            <asp:TextBox ID="tbxDataNasci" runat="server" SkinID="Data"></asp:TextBox>
                            <asp:CalendarExtender ID="tbxDataNasci_CalendarExtender" runat="server" 
                                Animated="False" ClearTime="True" CssClass="cal_Theme1" Enabled="True" 
                                 Format="dd/MM/yyyy" PopupPosition="BottomRight" TargetControlID="tbxDataNasci">
                            </asp:CalendarExtender>
                        </td>
                    </tr>
                 </table> 
                  <table width="100%">
                    <tr>
                        <td>
                            <asp:Label ID="lblEndereco" runat="server" Text="Endereço:" />
                            <br />
                            <asp:TextBox ID="tbxEndereco" runat="server" SkinID="Nome"></asp:TextBox>
                        </td>
                        <td>
                            <asp:Label ID="lblnumero" runat="server" Text="N°:" />
                            <br />
                            <asp:TextBox ID="tbxNumero" runat="server" SkinID="Numero"></asp:TextBox>
                        </td>
                        <td>
                            <asp:Label ID="lblBairro" runat="server" Text="Bairro:" />
                            <br />
                            <asp:TextBox ID="tbxBairro" runat="server" SkinID="Nome"></asp:TextBox>
                        </td>
                        <td>
                            <asp:Label ID="lblUF" runat="server" Text="UF:" />
                            <br />
                            <asp:DropDownList ID="ddlUF" runat="server" AutoPostBack="True" 
                                DataSourceID="odsUF" DataTextField="ufNome" DataValueField="ufNome" 
                                onselectedindexchanged="ddlUF_SelectedIndexChanged" SkinID="UF">
                            </asp:DropDownList>
                            <asp:ObjectDataSource ID="odsUF" runat="server" 
                                OldValuesParameterFormatString="original_{0}" SelectMethod="ObterUF" 
                                TypeName="SisVenda.Web.Restrito.Fn.CadastroPessoaFisicaFn">
                            </asp:ObjectDataSource>
                        </td>
                        <td>
                            <asp:Label ID="lblCidade" runat="server" Text="Cidade:" />
                            <br />
                            <asp:DropDownList ID="ddlCidade" runat="server" AutoPostBack="True" 
                                DataSourceID="odsCidade" DataTextField="cidade" DataValueField="idCidade" 
                                onselectedindexchanged="ddlCidade_SelectedIndexChanged" SkinID="Cidade">
                            </asp:DropDownList>
                             <asp:ObjectDataSource ID="odsCidade" runat="server" 
                                OldValuesParameterFormatString="original_{0}" SelectMethod="ObterCidadeUF" 
                                TypeName="SisVenda.Web.Restrito.Fn.CadastroPessoaFisicaFn">
                                <SelectParameters>
                                <asp:ControlParameter ControlID="ddlUF" Name="UfNome" 
                                    PropertyName="SelectedValue" Type="String" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                        </td>
                        <td>
                          <asp:Label ID="lblcep"  Text="Cep:" runat="server"></asp:Label>
                          <br />
                          <asp:TextBox ID="tbxCep" runat="server" SkinID="CEP"></asp:TextBox>
                        </td>
                     </tr>
                </table>
                  <table width="100%">
                 <tr>
                     <td>
                      <asp:Label ID="lblEstadoCivil" runat="server" Text="Estado Civil:" />
                            <br />
                      <asp:DropDownList ID="ddlEstadoCivil" runat="server" SkinID="EstadoCivil">
                      </asp:DropDownList>
                     </td>
                     <td>
                       <asp:Label ID="lblTipoTel" runat="server" Text="Tipo Telefone:"></asp:Label>
                       <br />
                       <asp:DropDownList ID="ddlTipoTel" runat="server" SkinID="TipoTelefone"></asp:DropDownList>
                     </td>
                     <td>
                        <asp:Label ID="lblTelefone" runat="server" Text="Telefone:"></asp:Label>
                         <br />
                         <asp:TextBox ID="tbxTelefone" runat="server" SkinID="Telefone"></asp:TextBox>
                         <asp:MaskedEditExtender ID="tbxTelefone_MaskedEditExtender" runat="server" 
                             SkinID="Fone" Enabled="True" 
                             TargetControlID="tbxTelefone">
                         </asp:MaskedEditExtender>
                     </td>
                     <td>
                        <asp:Label ID="lblCelular" runat="server" Text="Celular:"></asp:Label>
                         <br />
                         <asp:TextBox ID="tbxCeluar" runat="server" SkinID="Telefone"></asp:TextBox>
                         <asp:MaskedEditExtender ID="tbxCeluar_MaskedEditExtender" runat="server" 
                              SkinID="Fone" Enabled="True" 
                             TargetControlID="tbxCeluar">
                         </asp:MaskedEditExtender>
                     </td>
                     <td>
                        <asp:Label ID="lblFax" runat="server" Text="Fax:"></asp:Label>
                         <br />
                         <asp:TextBox ID="tbxFax" runat="server" SkinID="Telefone"></asp:TextBox>
                         <asp:MaskedEditExtender ID="tbxFax_MaskedEditExtender" runat="server" 
                             SkinID="Fone" Enabled="True" 
                             TargetControlID="tbxFax">
                         </asp:MaskedEditExtender>
                     </td>
                     <td>
                        <asp:Label ID="lblEmail"  Text="Email:" runat="server"></asp:Label>
                        <br />
                        <asp:TextBox ID="tbxEmail" runat="server" SkinID="Email"></asp:TextBox>
                     </td>
                 </tr>
                </table>
                </div>
                <div>
                   <asp:Panel ID="pnlRefPessoais" runat="server" GroupingText="Referências Pessoais" SkinID="SecaoCampos">
                      <asp:Panel ID="pnlGrid" runat="server" >
                              <table width="100%">
                                      <tr>
                                         <td>
                                        <asp:GridView ID="gvwRefPessoais" runat="server" SkinID="SemSelect" AutoGenerateColumns="false">
                                            <Columns>
                                                <asp:BoundField DataField="descricao"  HeaderText="Descrição" />
                                                <asp:BoundField DataField="telefone"  HeaderText="Telefone" />
                                            </Columns>
                                        </asp:GridView>
                                        </td>
                                       </tr>
                              </table>
                      </asp:Panel>
                      <asp:Panel ID="pnlCampos" runat="server" Visible="false" >
                           <table width="100%">
                                      <tr>
                                         <td>
                                             <asp:Label ID="lblDescricao" runat="server" Text="Descricação:"></asp:Label>
                                             <br />
                                             <asp:TextBox ID="tbxDescricao" runat="server" SkinID="Nome"></asp:TextBox>
                                         </td>
                                      </tr>
                                      <tr>
                                         <td>
                                             <asp:Label ID="lblTeleFoneRef" runat="server" Text="Telefone:"></asp:Label>
                                             <br />
                                             <asp:TextBox ID="tbxTeleFoneRef" runat="server" SkinID="Telefone"></asp:TextBox>
                                             <asp:MaskedEditExtender ID="tbxTeleFoneRef_MaskedEditExtender" runat="server" 
                                                  SkinID="Fone" Enabled="True" 
                                                 TargetControlID="tbxTeleFoneRef">
                                             </asp:MaskedEditExtender>
                                         </td>
                                      </tr>
                                     </table>
                                     <div class="acoes">
                                        <asp:Button ID="btnInserir" runat="server" CommandName="Insert" 
                                          SkinID="Inserir" onclick="btnInserir_Click" />
                                          &nbsp;<asp:Button ID="btnCancelar" runat="server" CausesValidation="False" 
                                           CommandName="Cancel" SkinID="Cancelar"
                                          
                                             onclientclick="return confirm('Os valores informados serão descartados e o registro não será inserido. Você confirma o cancelamento da operação?');" 
                                             onclick="btnCancelar_Click" />
                                     </div>
                      </asp:Panel>
                      <table width="100%">
                                <tr align="right">
                                    <td>
                                        <asp:Label ID="lblAlterar" runat="server" Text="false" ViewStateMode="Enabled" 
                                            Visible="False"></asp:Label>
                                        <asp:Button runat="server" ID="btnNovoRefPessoal" SkinID="Novo" 
                                            onclick="btnNovoRefPessoal_Click" /></td>
                                </tr>
                       </table>
                  </asp:Panel>
                </div>
              </asp:Panel>
              <asp:Panel runat="server">
              <table width="100%">
                            <tr>
                                <td style="width: 15%" align="right">
                                    <asp:Button ID="btnSalvar1" runat="server" Text="Concluir Cadastro" 
                                        ValidationGroup="Geral" onclick="btnSalvar1_Click" />
                                    &nbsp;<asp:Button ID="btnCancelarS" runat="server" Text="Cancelar" onclick="btnCancelarS_Click" />
                                    
                                </td>
                            </tr>
                        </table>
              
              </asp:Panel>
         </ContentTemplate>
          </asp:UpdatePanel>
</asp:Panel>
</asp:Content>
